package com.example.back.mapper;

import com.example.back.model.Boardgame;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface BoardgameMapper {
    @Select("select * from boardgame")
    List<Boardgame> findAllBoardgame();
    @Select("select * from boardgame where lowerLimit<=#{bCount} and upperLimit>=#{bCount}")
    List<Boardgame> selectBCount(int bCount);
    @Select("select * from boardgame where instr(name, #{name})>0")
    List<Boardgame> selectBName(String name);
    @Insert("insert into boardgame(name, introduction, upperLimit, lowerLimit, boardgame.rank, position) values(#{name}, #{introduction}, #{upperLimit}, #{lowerLimit}, #{rank}, #{position})")
    Boolean insertBoardgame(String name, String introduction, int lowerLimit, int upperLimit, int rank, int position);
    @Update("update boardgame set boardgame.rank=#{rank} where id=#{id}")
    Boolean updateRankByID(int id, int rank);
    @Update("update boardgame set position=#{position} where id=#{id}")
    Boolean updatePositionByID(int id, int position);
    @Delete("delete from boardgame where id=#{id}")
    Boolean deleteBoardgame(int id);
    @Select("select photo from boardgame where id=#{id}")
    String findPhotoByID(int id);
}
